package com.towker.core.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;

public class Environment
{
//	private static final Log log = LogFactory.getLog(Environment.class);
	private static final String SYSTEM_PROPERTIES_PATH = "/system.properties";
	private static Properties SYSTEM_PROPERTIES;

	private Environment()
	{
	}
	static
	{
		setSystemProperties(SYSTEM_PROPERTIES_PATH);
	}

	private static void setSystemProperties(String path)
	{
		SYSTEM_PROPERTIES = new Properties();
		InputStream stream = Environment.class.getResourceAsStream(path);
		if (stream == null)
		{
//			log.info(path + " not found");
		}
		else
		{
			try
			{
				SYSTEM_PROPERTIES.load(stream);
			}
			catch (Exception e)
			{
//				log.error("problem loading properties from " + path);
			}
			finally
			{
				try
				{
					stream.close();
				}
				catch (IOException ioe)
				{
//					log.error("could not close stream on " + path + ioe);
				}
			}
		}
		System.getProperties();
	}

	public static String getStrProperty(String name)
	{
		if (SYSTEM_PROPERTIES != null)
			return String.valueOf(SYSTEM_PROPERTIES.getProperty(name)).trim();
		return null;
	}
}
